$(function() {
	$('#huodg19').datagrid({
		//请求地址
	    url:'../check/getcheckAffairCategory',
	    columns:[[
	    	{field:'',title:'',checkbox:true},
	    	{field:'affairId',title:'事务编号',width:'10%' },
			{field:'affairName',title:'事务名称',width:'10%'},
			{field:'applicationType',title:'应用类型',width:'8%'},
			{field:'overtime',title:'加班种类',width:'8%'},
			{field:'remark',title:'备注',width:'20%'},
			{field:'maker',title:'创建者',width:'8%'},
			{field:'makeTime',title:'创建日期',width:'15%'},
			{field:'updateEmp',title:'修改者',width:'8%'},
			{field:'updateTime',title:'修改日期',width:'15%'},
			{field:'state',title:'状态',width:'5%',
				formatter : function(value, row, index) {
					if (row.state==='是') {
					var btns = "<a href='#' name='opera19' class='easyui-linkbutton' ></a>";
					return btns;
					}
				}
			} ] ],
			onLoadSuccess : function() {
				$("a[name='opera19']").linkbutton({
					plain : true,
					iconCls : 'icon-edit',
		    })
		       $("a[name='opera19']").bind('click',function(){
		    	   var rows = $('#huodg19').datagrid('getSelected');
		    	   if(rows.affairId!=null&&rows.affairId!=''){
		    		   $("#affairId").val(rows.affairId);
						$("#affairName").val(rows.affairName);
						$("#applicationType").val(rows.applicationType);
						$("#overtime").val(rows.overtime);
						$("#remark").val(rows.remark);
						$("#maker").val(rows.maker);
						$("#makeTime").val(rows.makeTime);
						$("#huodd19").window("open");  
		    	   }else{
		    		   alert("未选中数据");
		    	   }
					
				})
		},
		onLoadError:function(data){
			alert(12319)
		},
	    width:'100%',
	    fit:true,
	    //fit:true
	    fitColumns:true,
	    //隔行变色
	    striped:true,
	    nowrap:true,
	    //显示行号
	    rownumbers:true,
	    //设置单选
	    singleSelect:true,
		toolbar:'#huotb19',
		//显示分页栏
		pagination:true,
		//设置每页大小
		pageSize:5,
		//可选的每页大小
		pageList:[5,10,20,50]
		//绑定一个点击表格事件
	})
});
function searchname(value){
	 $('#huodg19').datagrid('load','../check/serchAffairCategory?serch_jsondata='+value);
} 


   var editIndex = undefined;
	function removeit(){
		if (editIndex == undefined){
			var rows = $('#huodg19').datagrid('getSelections');
			if(rows.length > 0){
				$.messager.confirm('请确认','您确定要删除当前所有选中的项目吗？',function(r){
					if(r){
						var holidayIds = [];
						for(var i = 0; i < rows.length; i++){
							holidayIds.push(rows[i].affairId)
						}
						var huo_rowData = JSON.stringify(holidayIds);
						alert(huo_rowData);
						$.ajax({
							url : "../check/deleteCheckAffairCategory",
							data : {"huo_rowData" : huo_rowData},
							success : function(e) {
								if (e == "ok") {
	                               alert("删除成功");
	                               $('#huodg19').datagrid('load');
								}
							}
						});
					}
				 })
				}
		}
		$('#huodg19').datagrid('cancelEdit', editIndex).datagrid('deleteRow', editIndex);
		editIndex = undefined;
	}